#include<bits/stdc++.h>
using namespace std;
int T;
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	cin >> T;
	while(T--)
	{
		cin >> a >> b;
		if(a > b) swap(a,b);
		if(a < 0 && 0 < b)
			cout << min({abs(a + b),abs(a),abs(b)}) << "\n";
		else
			cout << 0 << "\n";
	}
	return 0;
}
